<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="common/head.jsp"%>
<div class="right_col" role="main">
	<br /> <br /> <br /> <br /> <br />
	<div class="container">
		<br /> <br /> <br /> <br />
		<table class="display" id="example">
			<thead>
				<tr align="center">
					<th>评论编号</th>
					<th>趣事内容</th>
					<th>评论人</th>
					<th>评论时间</th>
					<th>评论地址</th>
					<th>评论内容</th>
					<th>点赞次数</th>
					<th>相关操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${commentList}" var="commentList">
					<tr align="center">
						<td>${commentList.sequnce}</td>
						<td>${commentList.thisContent}</td>
						<td>${commentList.userName}</td>
						<td>${commentList.datetime}</td>
						<td>${commentList.address}</td>
						<td>${commentList.content}</td>
						<td>${commentList.thumbUp}</td>
						<td>
							<div class="btn-group">
								<button style="height: 30px" type="button"
									class="btn btn-danger">操作</button>
								<button style="height: 30px" type="button"
									class="btn btn-danger dropdown-toggle" data-toggle="dropdown"
									aria-expanded="false">
									<span class="caret"></span> <span class="sr-only">Toggle
										Dropdown</span>
								</button>
								<ul class="dropdown-menu" role="menu"
									style="margin-left: -40px;">
									<li><a href="javascript:;" commentId="${commentList.id }"
										class="delComment">删除</a></li>
								</ul>
							</div>
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>
</div>
<script>
$(document).ready(function() {
	//评论删除
    $(".delComment").click(function() {
        var obj = $(this);
        var commentId = obj.attr("commentId");
        if (confirm("该评论涉及色情,低俗,暴力等不良内容吗?")) {
            if (confirm("真的要删除它吗?")) {
        $.ajax({
            type: "GET",
            url: "<%=basePath%>comment/delComment",
            data: {
                "commentId": commentId,
            },
            dataType: "json",
            success: function(data) {
                if (data.result == "true") {
                    alert("亲,恭喜您删除成功了");
                    window.location.href = "<%=basePath%>comment/showComment";
																	} else {
																		alert("对不起，删除失败了");
																	}
																},
																error : function(
																		data) {
																	alert("对不起，删除失败了");
																}
															});
												}
											}
										});
					});
</script>
<!--dataTables-->
<script charset="utf-8" type="text/javascript">
	$(document).ready(function() {
		$('#example').dataTable();
	});
</script>
<script type="text/javascript">
	$('#example').removeClass('display').addClass(
			'table table-striped table-bordered');
</script>
<!--dataTables-->
<%@ include file="common/foot.jsp"%>